package com.shuoyue.ycgk.ui.mine.mynote;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.google.android.material.tabs.TabLayout;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.BaseMvpActivity;
import com.shuoyue.ycgk.base.BaseMvpFragment;
import com.shuoyue.ycgk.base.baseadapter.IndexFragmentStateAdapter;
import com.shuoyue.ycgk.ui.mine.collection.CollectionListActivity;
import com.shuoyue.ycgk.views.viewpager_scroll.SuperViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class NotePagerActivity extends BaseMvpActivity {


    IndexFragmentStateAdapter indexFragmentAdapter;
    List<BaseMvpFragment> fragmentMainItems;
    @BindView(R.id.tab_layout)
    TabLayout tabLayout;
    @BindView(R.id.view_pager)
    SuperViewPager viewPager;

    int indexId = -1;//起点位置的ID

    public static void start(Context source, int position) {
        source.startActivity(new Intent(source, NotePagerActivity.class)
                .putExtra("indexId", position));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_note_pager;
    }

    @Override
    protected void initView() {
        indexId = getIntent().getIntExtra("indexId", -1);
        setTabType();

    }

    @Override
    public void initData() {

    }


    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }


    public void setTabType() {

        fragmentMainItems = new ArrayList<>();
        fragmentMainItems.add(NotedListFragment.getInstance(indexId));
        fragmentMainItems.add(PraisedListFragment.getInstance(indexId));

        indexFragmentAdapter = new IndexFragmentStateAdapter(getSupportFragmentManager(), fragmentMainItems);
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setAdapter(indexFragmentAdapter);

    }


}
